package com.test.qpbgboot.evaluation.controller;

import com.test.qpbgboot.base.response.JsonResult;
import com.test.qpbgboot.evaluation.pojo.dto.EscortEvaluationQuery;
import com.test.qpbgboot.evaluation.pojo.dto.EscortEvaluationSaveParam;
import com.test.qpbgboot.evaluation.pojo.dto.OrderEvaluationQuery;
import com.test.qpbgboot.evaluation.pojo.dto.OrderEvaluationSaveParam;
import com.test.qpbgboot.evaluation.pojo.vo.EscortEvaluationVO;
import com.test.qpbgboot.evaluation.pojo.vo.OrderEvaluationVO;
import com.test.qpbgboot.evaluation.service.EvaluationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/v1/evaluation")
@Slf4j
@Api(tags = "evaluation module")
public class EvaluationController {

    @Autowired
    private EvaluationService evaluationService;

    @GetMapping("/escort/select")
    @ApiOperation(value = "陪玩评价查询")
    public JsonResult selectEscortEvaluation(
            @Valid @ModelAttribute EscortEvaluationQuery escortEvaluationQuery) {
        log.debug("陪玩评价查询:escortEvaluationQuery={}", escortEvaluationQuery);
        List<EscortEvaluationVO> escortEvaluationVOList =
                evaluationService.escortEvaluationSelect(escortEvaluationQuery);
        return JsonResult.success(escortEvaluationVOList);
    }

    @PostMapping("/escort/save")
    @ApiOperation(value = "陪玩评价保存")
    public JsonResult saveEscortEvaluation(
            @Valid @RequestBody EscortEvaluationSaveParam
                    escortEvaluationSaveParam) {
        log.debug("陪玩评价保存:escortEvaluationSaveParam={}", escortEvaluationSaveParam);
        evaluationService.escortEvaluationSave(escortEvaluationSaveParam);
        return JsonResult.success();
    }

    @PostMapping("/escort/delete/{id}")
    @ApiOperation(value = "陪玩评价删除")
    public JsonResult deleteEscortEvaluation(@PathVariable @ApiParam(value = "陪玩评价id",
            name = "id", required = true) Long id) {
        log.debug("陪玩评价删除:id={}", id);
        evaluationService.escortEvaluationDelete(id);
        return JsonResult.success();
    }

    @GetMapping("/order/select")
    @ApiOperation(value = "订单评价查询")
    public JsonResult selectOrderEvaluation(
            @Valid @ModelAttribute OrderEvaluationQuery orderEvaluationQuery) {
        log.debug("订单评价查询:orderEvaluationQuery={}", orderEvaluationQuery);
        List<OrderEvaluationVO> orderEvaluationVOList = evaluationService
                .orderEvaluationSelect(orderEvaluationQuery);
        return JsonResult.success(orderEvaluationVOList);
    }


    @PostMapping("/order/save")
    @ApiOperation(value = "订单评价保存")
    public JsonResult saveOrderEvaluation(
            @Valid @RequestBody OrderEvaluationSaveParam orderEvaluationSaveParam) {
        log.debug("订单评价保存:orderEvaluationSaveParam={}", orderEvaluationSaveParam);
        evaluationService.orderEvaluationSave(orderEvaluationSaveParam);
        return JsonResult.success();
    }

    @PostMapping("/order/delete/{id}")
    @ApiOperation(value = "订单评价删除")
    public JsonResult deleteOrderEvaluation(@PathVariable @ApiParam(value = "订单评价id",
            name = "id", required = true) Long id) {
        log.debug("订单评价删除:id={}", id);
        evaluationService.orderEvaluationDelete(id);
        return JsonResult.success();
    }

}
